home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / CONTRSRC.ZIP / SRC / MORFLAME / MORFLAME.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-11-20  |  26.3 KB  |  995 lines

  1. ;--------------------------------------------------------------------------
  2. ; Wired '94 Morflame's Part ... Not very interesting, but always fun ...
  3. ; 386 minimum
  4. ; Programming : Morflame (Guy De Smet) october 1994
  5. ;--------------------------------------------------------------------------
  6.  
  7.         INCLUDE  PDFIK.INC
  8.         INCLUDE  VIDEO.INC
  9.         INCLUDE  PLAYINFO.INC
  10.  
  11. ;--------------------------------------------------------------------------
  12. ;                           Memory Struct        
  13. ;--------------------------------------------------------------------------
  14. .386        
  15.         DGROUP GROUP _DATA, _BSS
  16.         MRF_TEXT SEGMENT DWORD PUBLIC USE16 'CODE'
  17.                 ASSUME cs:MRF_TEXT, ds:_DATA2; , fs:DGROUP
  18.         MRF_TEXT ENDS
  19.         _DATA SEGMENT DWORD PUBLIC USE16 'DATA'
  20.         _DATA ENDS
  21.         _DATA2 SEGMENT DWORD PRIVATE USE16 'FAR_DATA'
  22.         _DATA2 ENDS
  23.         _BSS SEGMENT DWORD PUBLIC USE16 'BSS'
  24.         _BSS ENDS
  25. ;--------------------------------------------------------------------------
  26.  
  27. ;--------------------------------------------------------------------------
  28. ; constantes utiles
  29.   MAX_VERT=1000
  30.   MAX_POL=700
  31.   MAX_OBJ=50
  32.   Larg=320
  33.   Haut=200
  34.   Screen1 = 0
  35.   Screen2 = (Larg*Haut/4)
  36.   Screen3 = ((Larg*Haut/4)*2)
  37. ;--------------------------------------------------------------------------
  38. _DATA2 SEGMENT
  39.    ; Files data pointers
  40.         
  41.         Fic3d   WORD ?
  42.         Ceil      WORD ?
  43.         mapping   WORD ?
  44.         logo    WORD ?
  45.  
  46.    ; for the page switching 
  47.         SW byte 0
  48.  
  49.    ; cpu_time
  50.         cpu_flag byte 0
  51.  
  52.    ; tables :
  53.         INCLUDE TABLES2.INC
  54.         INCLUDE PALETTE.SPR
  55.    
  56.    ; Drawing precision
  57.        precision byte 1
  58.  
  59.    ; Animation counter  ----> SCRIPT
  60.        frame_animation word 0
  61.  
  62.    ; Animation step (incrémentation units) ---> SYNCHRONISATION
  63.        pas_animation word 0
  64.  
  65.    ; Lighting
  66.        luminosite byte 0
  67.  
  68. ;---- param for synchro with musak ----
  69. EVEN
  70. DebSong  WORD ?
  71. FinSong  WORD ?
  72.  
  73. ;---- param pour fading ----
  74. Timeleft WORD ?         ; time left for execute
  75. FadeFlag WORD ?         ; fading flag
  76. FadePtr1 WORD 2 DUP(?)  ; palette fading pointer
  77. FadePtr2 WORD 2 DUP(?)
  78. Delai    WORD ?
  79. Termine  WORD 0         ; end flag!
  80.  
  81. Dest     DW ?           ; working screen
  82.  
  83. cumul_step_lo DD 0
  84. cumul_step_hi DD 0
  85. cumul_old_lo DD 0
  86. cumul_old_hi DD 0
  87.  
  88. Automatic DW 1
  89.  
  90. _DATA2 ENDS
  91.  
  92. _DATA SEGMENT
  93.  
  94. ;-- data pattern --
  95. EXTRN _Datafile  : BYTE
  96. EXTRN _OfsinDta  : DWORD
  97.        Ficname    BYTE 'world.v3d',0
  98.        Ficparam   PARAM_STRUC<2,DGROUP,OFFSET _Datafile,OFFSET Ficname,0,0,0,,,0>
  99.        Ficname2   BYTE 'morceil.bin',0
  100.        Ficparam2  PARAM_STRUC<2,DGROUP,OFFSET _Datafile,OFFSET Ficname2,0,0,0,,,0>
  101.        Ficname3  BYTE 'morfloor.bin',0
  102.        Ficparam3 PARAM_STRUC<2,DGROUP,OFFSET _Datafile,OFFSET Ficname3,0,0,0,,,0>
  103.        Ficname4  BYTE 'morcon.raw',0
  104.        Ficparam4 PARAM_STRUC<2,DGROUP,OFFSET _Datafile,OFFSET Ficname4,0,0,0,,,0>
  105.  
  106.          EXTRN _FrameCounter     : WORD
  107.          EXTRN _ExitDemo         : WORD
  108.          EXTRN _SpaceBar         : WORD
  109.          EXTRN _CPUtime          : WORD
  110.          EXTRN _StartAdr         : WORD
  111.          EXTRN _WorkAdr          : WORD
  112.          EXTRN _NextAdr          : WORD
  113.          EXTRN _Triple           : WORD
  114.          EXTRN _SyncFlag         : WORD
  115.  
  116.         ;!!!!!!!!!! sync music !!!!!!!!!!
  117.         EXTRN _MP               : DWORD ; extern ModulePlayer * MB
  118.         EXTRN _ReplayInfo       : mpInformation
  119.  
  120. EXTRN _TmpPal           : BYTE
  121. EXTRN _FadeON           : WORD
  122.  
  123.  
  124. EXTRN _BlackPal: BYTE
  125. EXTRN _WhitePal: BYTE
  126.  
  127.  
  128. _DATA ENDS
  129.  
  130. MRF_TEXT SEGMENT
  131.      EXTRN _AveragePAL: FAR
  132.  
  133.  
  134. ALIGN
  135. EVEN
  136. ; macros 
  137. INCLUDE MEMOIRE.INC             ; memory 
  138. INCLUDE MORGMAC.INC             ; graphics
  139. INCLUDE 320x200.INC             ; mode x routines (320x200 60Hz)
  140. INCLUDE TRACING.INC             ; morflame's main drawing routines
  141.  
  142. ;------------------------------------------------------------------------------
  143. SYNC_FRAME MACRO code, label
  144. ; Do a loop based upon animation step...
  145. LOCAL boucle_sync
  146. IF CODE EQ 0
  147.                 mov         cx, pas_animation
  148. label:          push        cx
  149. ELSEIF CODE EQ 1
  150.          
  151.                 pop         cx
  152.                 dec         cx
  153.                 jnz         label
  154. ENDIF
  155.  
  156. ENDM
  157. ;------------------------------------------------------------------------------
  158. LUMIERE MACRO        
  159. LOCAL paloo        
  160.         pusha
  161.         mov     ah,0               
  162.         mov     al,0                    ;the first color to write is # 0
  163.         mov     cx,256*3                ;nb of bytes to write
  164.         mov     dx,03c8h                ;VGA PEL address write mode register
  165.         out     dx,al
  166.         inc     dx                      ;VGA PEL data register (03c9h)
  167. paloo:  lodsb   [si]
  168.         mul     bl
  169.         mov     al,ah
  170.         out     dx,al
  171.         loop    paloo
  172.         popa
  173. ENDM
  174. ;------------------------------------------------------------------------------
  175. AFFICHE_LOGO MACRO
  176. LOCAL Cbcl1,Cbcl2
  177. ; put pict on the 4 pages (why not ?)
  178.         push    ds
  179.         push    es
  180.         mov     ax,Logo
  181.         mov     ds,ax
  182.         mov     si,800                ; skip Alchemy header
  183.  
  184.         mov     dx,3c4h
  185.         mov     al,02h                ; bitplane sel. reg.
  186.         out     dx,al
  187.         inc     dl  
  188.         
  189.         cld
  190.         mov     ax,0a000h
  191.         mov     es,ax
  192.         i3=0
  193.         REPT    4
  194.         xor     di,di
  195.         mov     al,(1 SHL i3)
  196.         out     dx,al
  197.         mov     cx,320*200/4
  198. @@:     lodsb
  199.         add     si,3
  200.         stosb
  201.         dec     cx
  202.         jnz     @B
  203.         sub     si,320*200-1
  204.         i3=i3+1
  205.         ENDM
  206.  
  207.         mov     dx,3c4h
  208.         mov     ax,0f02h
  209.         out     dx,ax
  210.  
  211.         mov     dx,3ceh
  212.         mov     ax,4105h  ; WRITE MODE 1
  213.         out     dx,ax
  214.  
  215.         cld
  216.         mov     ax,0a000h
  217.         mov     ds,ax
  218.         mov     cx,65536-80*200
  219.         xor     si,si
  220.         mov     di,80*200
  221.         rep     movsb
  222.  
  223.         mov     dx,3ceh
  224.         mov     ax,4005h  ; WRITE MODE 0
  225.         out     dx,ax
  226.  
  227.         
  228.         pop     es
  229.         pop     ds
  230. ENDM
  231.  
  232.          EXTRN   _WaitVBL : FAR
  233.          PUBLIC  _Morflame1
  234. ;------------------------------------------------------------------------------
  235. ;                  P R O C E D U R E   P R I N C I P A L E
  236. ;------------------------------------------------------------------------------
  237. ALIGN
  238. EVEN
  239. _Morflame1 PROC FAR
  240.         push    bp
  241.         mov     bp, sp
  242.         pushad
  243.         MPUSH   ds,es,fs,gs 
  244.         LSDS    _DATA2, ax
  245.  
  246. ;------- recuperer parametres sur le stack !!!! --------
  247.          xor     eax,eax
  248.          mov     ax,WORD PTR ss:[bp+6]  ; debut pos
  249.          shl     eax,14
  250.          or      ax,WORD PTR ss:[bp+8]  ; debut row
  251.          or      ah,al
  252.          shr     eax,8
  253.          mov     DebSong,ax
  254.          xor     eax,eax
  255.          mov     ax,WORD PTR ss:[bp+10] ; fin pos
  256.          shl     eax,14
  257.          or      ax,WORD PTR ss:[bp+12] ; fin row
  258.          or      ah,al
  259.          shr     eax,8
  260.          mov     FinSong,ax
  261.          xor     eax,eax
  262. ;-------------------------------------------------------
  263.  
  264.  
  265.         call    Part1
  266.  
  267.         mov     ax,DGROUP
  268.         mov     fs,ax
  269.         mov     fs:_FadeON,0
  270.  
  271.         mov     dx,3c4h
  272.         mov     ax,0f02h
  273.         out     dx,ax
  274.         mov     ax,0a000h
  275.         mov     es,ax
  276.         xor     di,di
  277.         mov     cx,65536/4
  278.         xor     eax,eax
  279.         rep     stosd
  280.  
  281.         MPOP    ds,es,fs,gs
  282.         popad
  283.         nop
  284.         leave
  285.         retf
  286. _Morflame1 ENDP
  287. ;------------------------------------------------------------------------------
  288. ;                      P A R T I E  D O O M  S T Y L E
  289. ;------------------------------------------------------------------------------
  290. ALIGN
  291. EVEN
  292. Part1 PROC
  293.  
  294. ; some macros .....
  295.  
  296. TESTEND  MACRO
  297.          LOCAL lbl1,lbl2
  298.  
  299.          pushad
  300.          MPUSH    ds,es,fs,gs
  301.  
  302. ;==============================================
  303.          mov      ax,DGROUP
  304.          mov      ds,ax                   ; xchg FS,DS
  305.          mov      ax,_DATA2
  306.          mov      fs,ax
  307.  
  308.          ASSUME   ds:DGROUP,fs:_DATA2
  309.  
  310. ;----------- test if we must finish ... ----------
  311.  
  312.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  313.  
  314.          les     bx,DWORD PTR[_MP]
  315.          push    ds
  316.          push    OFFSET _ReplayInfo
  317.  
  318.          ; _MP->GetInformation(&ReplayInfo)
  319.  
  320.          call    (ModulePlayer PTR es:[bx]).GetInformation
  321.          add     sp,4
  322.  
  323.          mov     ax,_ReplayInfo.pos
  324.          shl     eax,14
  325.          or      ax,_ReplayInfo.row
  326.          or      ah,al
  327.          shr     eax,8
  328.          cmp     ax,WORD PTR fs:[FinSong]; is it time ????
  329.          jae     lbl2                    ; to fade out ???
  330.  
  331. ;+++++++++++++++++++++++++++++++++++++++
  332.          cmp     frame_animation,3500    ; in all cases, do fade out !!!
  333.          jb      lbl1
  334. ;+++++++++++++++++++++++++++++++++++++++
  335.  
  336. lbl2:
  337.          mov     fs:Termine,1
  338.  
  339.          cmp     FadePtr2,OFFSET _BlackPal
  340.          je      lbl1
  341.          mov     fs:FadeFlag,0
  342.          mov     eax,DWORD PTR fs:[FadePtr2]
  343.          mov     DWORD PTR fs:[FadePtr1],eax   ; fade to black !!!!
  344.          mov     ax,ds
  345.          mov     fs:FadePtr2+2,ax
  346.          mov     fs:FadePtr2,OFFSET _BlackPal
  347.  
  348. lbl1:      xor     eax,eax
  349.  
  350.          ASSUME  ds:_DATA2, fs:DGROUP
  351.  
  352.          MPOP    ds,es,fs,gs
  353.          popad
  354.          nop
  355.  
  356. ENDM
  357.  
  358. FADEPAL MACRO
  359.         LOCAL NewFade,Faddi,lbl1
  360.  
  361. ;===================== Fade Palette ===========================
  362.  
  363.          mov     ax,DGROUP
  364.          mov     fs,ax
  365.          mov     ax,_DATA2
  366.          mov     ds,ax
  367.  
  368.          cmp     FadeFlag,255
  369.          jb      NewFade
  370.  
  371.          mov     fs:_FadeON,0  ; plus fader ...
  372.  
  373.          cmp     Termine,1    ; Terminer si dernier fade fini
  374.          je      endl
  375.  
  376.          mov     fs:_FadeON,0    ; don't set _TmpPal anymore ...
  377.          jmp     lbl1
  378. NewFade: MPUSH   ax,cx
  379.  
  380.          mov     ax,FadeFlag  ; average Black-MyPal
  381.          push    ax
  382.          push    fs
  383.          push    OFFSET _TmpPal
  384.          mov     ax,FadePtr1+2
  385.          push    ax
  386.          mov     ax,FadePtr1
  387.          push    ax
  388.          mov     ax,FadePtr2+2
  389.          push    ax
  390.          mov     ax,FadePtr2
  391.          push    ax
  392.          call    _AveragePAL
  393.          add     sp,7*2
  394.          mov     fs:_FadeON,1 ;1            ; set new PAL during next VR !!!!
  395.          mov     cx,fs:_FrameCounter
  396.          sub     cx,Delai             ; temps chargement
  397.          mov     Delai,0              ; plus delai ....
  398.          test    cx,cx
  399.          jnz     Faddi
  400.          mov     cx,1
  401. Faddi:   add     FadeFlag,4           ; inc fade ..
  402.          dec     cx
  403.          jnz     Faddi
  404.  
  405.          MPOP    ax,cx
  406. lbl1:
  407. ;==============================================================
  408.  
  409. ENDM
  410.  
  411. ;*************** Here begins the code !!!! *************
  412.  
  413.  
  414.         push    bp
  415.         mov     bp, sp
  416.  
  417.         pushad 
  418.         MPUSH   ds,es,fs,gs
  419.  
  420.  
  421.  
  422.  
  423.         LSDS    _DATA2, ax
  424.  
  425. ;------------------------------------------------------------------------------
  426. ;           L E C T U R E   F I C H I E R S  T E X T U R E S
  427. ;------------------------------------------------------------------------------
  428.          
  429.          push    ds
  430.          assume  ds:DGROUP
  431.          LSDS    DGROUP, ax
  432.          mov     eax,_OfsinDta         ; OFFSET in Datafile
  433.          mov     (Ficparam3.OfsInPdf),eax
  434.          mov     ax,DGROUP             ; prepare for PDFIK call
  435.          mov     es,ax
  436.          mov     bx,OFFSET Ficparam3
  437.          pusha
  438.          call    PDFIK_ASM             ; call function 2 (extract+alloc)
  439.          popa
  440.          mov     ax,(Ficparam3.BufSeg) ; where is the file in mem ?
  441.          pop     ds
  442.          assume  ds:_DATA2
  443.          mov     mapping,ax
  444.  
  445.  
  446.          push    ds
  447.          assume  ds:DGROUP
  448.          LSDS    DGROUP, ax
  449.          mov     eax,_OfsinDta         ; OFFSET in Datafile
  450.          mov     (Ficparam2.OfsInPdf),eax
  451.          mov     ax,DGROUP             ; prepare for PDFIK call
  452.          mov     es,ax
  453.          mov     bx,OFFSET Ficparam2
  454.          pusha
  455.          call    PDFIK_ASM             ; call function 2 (extract+alloc)
  456.          popa
  457.          mov     ax,(Ficparam2.BufSeg) ; where is the file in mem ?
  458.          pop     ds
  459.          assume  ds:_DATA2
  460.          mov     ceil,ax
  461.  
  462. ;------------------------------------------------------------------------------
  463. ;               L E C T U R E   F I C H I E R     L O G O
  464. ;------------------------------------------------------------------------------
  465.  
  466.          push    ds
  467.          assume  ds:DGROUP
  468.          LSDS    DGROUP, ax
  469.          mov     eax,_OfsinDta         ; OFFSET in Datafile
  470.          mov     (Ficparam4.OfsInPdf),eax
  471.          mov     ax,DGROUP             ; prepare for PDFIK call
  472.          mov     es,ax
  473.          mov     bx,OFFSET Ficparam4
  474.          pusha
  475.          call    PDFIK_ASM             ; call function 2 (extract+alloc)
  476.          popa
  477.          mov     ax,(Ficparam4.BufSeg) ; where is the file in mem ?
  478.          pop     ds
  479.          assume  ds:_DATA2
  480.          mov     logo,ax
  481.  
  482.  
  483. ;------------------------------------------------------------------------------
  484. ;                           S E T M O D E     X
  485. ;------------------------------------------------------------------------------
  486.  
  487.         mov     ax, DGROUP
  488.         mov     ds, ax
  489.  
  490.         push    m320x200x256p ;60Hz
  491.         call    _SetVGA
  492.         add     sp,2
  493.  
  494.         mov     ax, _DATA2
  495.         mov     ds, ax
  496.  
  497.  
  498. ;---- wait right position/row in tune ----
  499.  
  500.         MPUSH eax,bx,ds,es,fs
  501.  
  502.         ASSUME  ds:DGROUP
  503.         ASSUME  fs:_DATA2
  504.         mov     ax,DGROUP
  505.         mov     ds,ax
  506.         mov     ax,_DATA2   ; XCHG DS,FS !!!!
  507.         mov     fs,ax
  508.  
  509. ;;;;; attente bonne position music ;;;;;
  510. WaitPos:
  511.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  512.  
  513.          les     bx,DWORD PTR [_MP]
  514.          push    ds
  515.          push    OFFSET _ReplayInfo
  516.  
  517.          ; _MP->GetInformation(&ReplayInfo)
  518.  
  519.          call    (ModulePlayer PTR es:[bx]).GetInformation
  520.          add     sp,4
  521.  
  522.          mov     ax,_ReplayInfo.pos
  523.          shl     eax,14
  524.          or      ax,_ReplayInfo.row
  525.          or      ah,al
  526.          shr     eax,8
  527.          cmp     ax,WORD PTR fs:[DebSong]  ; is it time ????
  528.          jb      WaitPos
  529.          xor     eax,eax
  530.          
  531.          ASSUME  ds:_DATA2
  532.          ASSUME  fs:DGROUP
  533.  
  534.          MPOP eax,bx,ds,es,fs
  535.  
  536.  
  537. ;------------------------------------------
  538.  
  539. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  540.          mov     ax,DGROUP
  541.          mov     fs,ax
  542.          mov     ax,_DATA2
  543.          mov     ds,ax
  544. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  545.  
  546.  
  547. ; init ....
  548.           mov     Termine,0
  549.  
  550.          ASSUME ds:_DATA2, fs:DGROUP
  551.  
  552.          mov     fs:_FadeON,0
  553.          mov     FadeFlag,0
  554.  
  555.          mov     FadePtr1,OFFSET _BlackPal  ; Black to pic for the beginning !!!
  556.          mov     ax,fs
  557.          mov     FadePtr1+2,ax
  558.          mov     FadePtr2,OFFSET pal
  559.          mov     ax,ds
  560.          mov     FadePtr2+2,ax
  561.  
  562.          mov     fs:_FrameCounter,0
  563.          mov     Delai,0 
  564. ;------------------------------------------------------------------------------
  565. ;                      I N I T I A L I S A T I O N S
  566. ;------------------------------------------------------------------------------
  567.  
  568.         LSFS    DGROUP, ax
  569.  
  570.         mov     bx,fs:_StartAdr
  571.         mov     WORD PTR fs:[bx],Screen1   ; _StartAdr->base = 0
  572.         mov     WORD PTR fs:[bx+2],0       ; _StartAdr->flag = false
  573.         mov     bx,fs:_WorkAdr
  574.         mov     WORD PTR fs:[bx],Screen2   ; _WorkAdr->base
  575.         mov     WORD PTR fs:[bx+2],0       ; _WorkAdr->flag = false
  576.         mov     bx,fs:_NextAdr
  577.         mov     WORD PTR fs:[bx],Screen3   ; _NextAdr->base
  578.         mov     WORD PTR fs:[bx+2],0       ; _NextAdr->flag = false
  579.         mov     fs:_Triple,1               ; triple buffering
  580.  
  581.         call    _WaitVBL
  582.  
  583.         mov     fs:_FrameCounter,0
  584.  
  585.  
  586. ;------------------------------------------------------------------------------
  587.  
  588.  
  589. ;------------------------------------------------------------------------------
  590. ;                    B O U C L E   P R I N C I P A L E
  591. ;------------------------------------------------------------------------------
  592.         Affiche_Logo
  593.         
  594.         LSFS    DGROUP, ax
  595.         mov     frame_animation, 1123
  596.         mov     fs:_FrameCounter, 0        
  597.  
  598. ;============================== MAIN LOOP ===============================
  599.         
  600. main_loop:
  601.         
  602.         LSFS    DGROUP, ax
  603.  
  604. ;***** 2nd page *****
  605. Do_a_frame:
  606.         mov     di,fs:_WorkAdr
  607.         cmp     WORD PTR fs:[di+2],1; _WorkAdr->flag true (previous _NextAdr) ?
  608.         je      NextFrame           ; then construct next frame
  609.  
  610.         mov     Dest,di             ; save pointer
  611.  
  612.         FADEPAL                     ; fade palet !!!
  613.  
  614.         call    SUPER_MORFLAME      ; all code of Wolf's Morflame :-)
  615.  
  616.         ; exit
  617.  
  618.         cmp     frame_animation, 3995
  619.         jg      endl
  620.  
  621.  
  622.         TESTEND                 ; look at the tune to know if we must exit !!!!
  623.  
  624.  
  625.         LSFS    DGROUP, ax
  626.  
  627.         mov     di,fs:_NextAdr       ; save adr of next buffer
  628.  
  629.         mov     bx,Dest
  630.         mov     WORD PTR fs:[bx+2],1 ; _WorkAdr->flag = true
  631.  
  632.         jmp     Nexxxt
  633.  
  634. ;******** 3rd page *********
  635. NextFrame:
  636.         mov     di,fs:_NextAdr
  637.         cmp     WORD PTR fs:[di+2],1  ; _NextAdr true ?
  638.         je      NextFrame
  639.     
  640. Nexxxt:
  641.         mov     Dest,di               ; save pointer
  642.  
  643.         FADEPAL                       ; fade palet !!!
  644.  
  645.         call    SUPER_MORFLAME        ; all code of Wolf's Morflame :-)
  646.  
  647.         ; exit
  648.  
  649.         cmp     frame_animation, 3995
  650.         jg      endl
  651.  
  652.         TESTEND       ; look at the tune to know if we must exit !!!!
  653.  
  654.         LSFS   DGROUP, ax
  655.  
  656.         mov    bx,Dest
  657.         mov    WORD PTR fs:[bx+2],1     ; _NextAdr->flag = true
  658.  
  659.  
  660.         mov     ax,DGROUP
  661.         mov     fs,ax
  662.  
  663.         in      al, 60h                            ; buffer clavier
  664.         cmp     al, 78                             ; '+' ?
  665.         jnz     @F
  666.         mov     fs:_CPUtime, 1
  667.         mov     cpu_flag, 1
  668.         Free_Keyboard
  669. @@:     cmp     al, 74                             ; '-' ?
  670.         jnz     @F
  671.         mov     fs:_CPUtime, 0
  672.         mov     cpu_flag, 0
  673.         Free_Keyboard
  674. @@:     cmp     al, 68                             ; 'F10' ?
  675.         jnz     @F
  676.         mov     precision, 0
  677.         mov     Automatic,0
  678.         Free_Keyboard
  679. @@:     cmp     al, 87                             ; 'F11' ?
  680.         jnz     @F
  681.         mov     precision, 1
  682.         mov     Automatic,0
  683.         Free_Keyboard
  684.  
  685. @@:     cmp     al, 39h                            ; space bar ???
  686.         jne     @F
  687.         mov     fs:_SpaceBar,1                     ; skip part !!!
  688.         jmp     endl
  689.  
  690. @@:     cmp     al, 1                              ; esc ?
  691.         jnz     main_loop
  692.         mov     fs:_ExitDemo,1                     ; EXIT DEMO !
  693. endl:
  694.         Free_Keyboard
  695.  
  696. ;============================= END LOOP ======================================
  697.  
  698. ;------------------------------------------------------------------------------
  699. ; Libération des zones mémoires
  700.  
  701.         mov     fs:_FadeON,0 ; stop fading ...
  702.  
  703.         FREE logo
  704.         FREE ceil
  705.         FREE mapping
  706.  
  707.         Free_Keyboard
  708.  
  709.         MPOP    ds,es,fs,gs
  710.         popad
  711.         nop
  712.  
  713.         leave
  714.  
  715.         ret
  716.  
  717. error:
  718.         xor     bx, bx
  719.         mov     ax, 0E07h
  720.         int     10h
  721.  
  722.         MPOP     ds,es,fs,gs
  723.         popad
  724.         nop
  725.  
  726.         leave
  727.  
  728.         ret
  729.  
  730. Part1 ENDP
  731.  
  732. SUPER_MORFLAME PROC NEAR
  733.  
  734. ;------------------------------------------------------------------------------
  735. ;                P R O C E D U R E  D ' A F F I C H A G E
  736. ;------------------------------------------------------------------------------
  737.  
  738. ; one proc for all MAIN LOOP code
  739.  
  740. ;------------ FrameCounter manip ------------
  741.         MPUSH  eax,ebx,ecx,edx
  742.  
  743.         mov    cx,fs:_FrameCounter
  744.         test   cx,cx
  745.         jnz    @F
  746.         mov    cx,1
  747.  
  748. @@:     xor    eax,eax
  749.         mov    ax,409 ;1.6*256 ;384 ;1.5*256 486            ; 1.9*256
  750.         mul    cx
  751.  
  752.  
  753.         mov    ecx,cumul_step_lo   ; save old cumulated step (64 bits)
  754.         mov    cumul_old_lo,ecx
  755.         mov    ecx,cumul_step_hi
  756.         mov    cumul_old_hi,ecx   
  757.      
  758.         add    cumul_step_lo,eax   ; multiprecision
  759.         adc    cumul_step_hi,0
  760.  
  761.         mov    ecx,cumul_step_hi
  762.         mov    eax,cumul_step_lo
  763.         shrd   eax,ecx,8           ; / 256
  764.         mov    edx,cumul_old_hi
  765.         mov    ebx,cumul_old_lo
  766.         shrd   ebx,edx,8
  767.  
  768.         sub    eax,ebx
  769. ;       sbb    ecx,edx
  770.  
  771.  
  772.         mov    pas_animation,ax  ; PAS_ANIMATION = 1.999 * FrameCounter
  773.  
  774.         test   Automatic,1
  775.         jz     skip_auto_ajust
  776.  
  777.         cmp    ax,7
  778.         jle    @F
  779.         mov    precision,0      ; low detail if too many steps (slow) !!
  780. @@:     cmp    ax,2             ; high detail if fast!
  781.         ja     @F
  782.         mov    precision,1
  783. @@:
  784.  
  785. skip_auto_ajust:
  786.  
  787.         MPOP   eax,ebx,ecx,edx
  788. ;--------------------------------------------
  789.  
  790.         mov    fs:_FrameCounter,0
  791.  
  792.         CPU_TIME 48
  793.         
  794.         ; Fucking animation processing ... no time to do better !
  795.  
  796.         mov     ax, pas_animation
  797.         add     frame_animation, ax
  798.  
  799.         ; Début vide actuellement
  800.         
  801.         cmp     frame_animation,  868
  802.         jle     end_anim
  803.         
  804.         cmp     precision, 0
  805.         jnz     @F
  806.         call FLOORS_LOW_DETAIL
  807. @@:     cmp     precision, 1
  808.         jnz     @F
  809.         call FLOORS_MEDIUM_DETAIL
  810. @@:
  811.         cmp     frame_animation,  868
  812.         jge     a1
  813.         jmp     end_anim
  814.  
  815.  
  816. a1:     cmp     frame_animation, 1123
  817.         jle     end_anim
  818.         
  819.         ; --------------
  820.         ; first passage
  821.         ; --------------
  822.         
  823.         cmp     frame_animation, 1253
  824.         jge     a2
  825.         SYNC_FRAME 0, sync1
  826.         sub     cam_y, 4096
  827.         SYNC_FRAME 1, sync1
  828.         jmp     end_anim
  829.  
  830.  
  831.         ; ---------------------------------------------
  832.         ; cul-de-sac, looking for exit
  833.         ; ---------------------------------------------
  834. a2:     cmp     frame_animation, 1319
  835.         jge     a3
  836.         SYNC_FRAME 0, sync2
  837.         Tourne_gauche 2
  838.         sub     cam_y, 512        ; -10
  839.         SYNC_FRAME 1, sync2
  840.  
  841.         jmp     end_anim        
  842.  
  843.         ; ---------------------------------------------
  844.         ; to exit
  845.         ; ---------------------------------------------
  846. a3:     cmp     frame_animation, 1339
  847.         jge     a4
  848.         SYNC_FRAME 0, sync3
  849.         add     cam_y, 2226
  850.         add     cam_x, 1536
  851.         SYNC_FRAME 1, sync3
  852.         jmp     end_anim        
  853. a4:     cmp     frame_animation, 1379
  854.         jge     a5        
  855.         SYNC_FRAME 0, sync4
  856.         Tourne_Droite 1
  857.         add     cam_y, 1280
  858.         add     cam_x, 1536
  859.         SYNC_FRAME 1, sync4
  860.         jmp     end_anim        
  861.         ; -------------
  862.         ; to big room
  863.         ; -------------
  864. a5:     cmp     frame_animation, 1620
  865.         jge     a11
  866.         SYNC_FRAME 0, sync5
  867.         add     cam_x, 2048
  868.         SYNC_FRAME 1, sync5
  869.         jmp     end_anim
  870.  
  871. a11:    cmp     frame_animation, 1670
  872.         jge     a12
  873.         SYNC_FRAME 0, sync11
  874.         add     cam_x, 819
  875.         Tourne_Gauche 1
  876.         SYNC_FRAME 1, sync11
  877.         jmp     end_anim
  878.  
  879.         ; ----------
  880.         ; Big room
  881.         ; ----------
  882. a12:    cmp     frame_animation, 1675
  883.         jl      end_anim
  884.  
  885. a13:    cmp     frame_animation, 1715
  886.         jge     a14
  887.         SYNC_FRAME 0, sync13
  888.         add     cam_x, 512
  889.         add     cam_y, 1024
  890.         Tourne_Gauche 1
  891.         SYNC_FRAME 1, sync13
  892.         jmp     end_anim
  893.  
  894. a14:    cmp     frame_animation, 1770
  895.         jge     a15
  896.         SYNC_FRAME 0, sync14
  897.         add     cam_y, 1024
  898.         SYNC_FRAME 1, sync14
  899.         jmp     end_anim
  900. a15:    cmp     frame_animation, 1940
  901.         jge     a16
  902.         SYNC_FRAME 0, sync15
  903.         add     cam_y, 1012
  904.         add     cam_x, 128                      ; ACHTUNG (huh?)
  905.         Tourne_Droite 1
  906.         SYNC_FRAME 1, sync15
  907.         jmp     end_anim
  908.  
  909. a16:    cmp     frame_animation, 2130
  910.         jl      end_anim
  911. a17:    cmp     frame_animation, 2440
  912.         jge     a18
  913.         SYNC_FRAME 0, sync17
  914.         sub     cam_y, 1500
  915.         SYNC_FRAME 1, sync17
  916.         jmp     end_anim
  917.  
  918. ; new cul-de-sac
  919.  
  920. a18:    cmp     frame_animation, 2440
  921.         jge     a19
  922.         SYNC_FRAME 0, sync18
  923.         add     cam_y, 20
  924.         SYNC_FRAME 1, sync18
  925.         jmp     end_anim
  926.  
  927. a19:    cmp     frame_animation, 2530
  928.         jge     a20
  929.         SYNC_FRAME 0, sync19
  930.         add     cam_y, 60
  931.         SYNC_FRAME 1, sync19
  932.         jmp     end_anim
  933.  
  934. a20:    cmp     frame_animation, 2720
  935.         jge     a21
  936.         SYNC_FRAME 0, sync20
  937.         add     cam_y, 200
  938.         sub     cam_x, 3
  939.         SYNC_FRAME 1, sync20
  940.         jmp     end_anim
  941.  
  942. a21:    cmp     frame_animation, 2880
  943.         jge     a22
  944.         SYNC_FRAME 0, sync21
  945.         Tourne_Gauche 1
  946.         SYNC_FRAME 1, sync21
  947.         jmp     end_anim
  948.  
  949. a22:    cmp     frame_animation, 3140
  950.         jge     a23
  951.         SYNC_FRAME 0, sync22
  952.         cmp     cam_y, 780736              ; for correct centering
  953.         jge     @F
  954.         add     cam_y, 2200
  955. @@:     SYNC_FRAME 1, sync22
  956.         jmp     end_anim
  957.  
  958. ; The last passage .................................... !
  959.  
  960. a23:    cmp     frame_animation, 3240
  961.         jge     a24
  962.         SYNC_FRAME 0, sync23
  963.         cmp     cam_y, 884736              ; for correct centering
  964.         jge     @F
  965.         add     cam_y, 1170
  966. @@:     sub     cam_x, 20
  967.         Tourne_Gauche 1
  968.         SYNC_FRAME 1, sync23
  969.         jmp     end_anim
  970. a24:    cmp     frame_animation, 3580
  971.         jge      a25
  972.         SYNC_FRAME 0, sync24
  973.         sub     cam_x, 1500
  974.         SYNC_FRAME 1, sync24
  975.         jmp     end_anim
  976.  
  977. a25:
  978.  
  979. afin:
  980.  
  981. end_anim:
  982.  
  983.         CPU_TIME 0
  984.  
  985. ;-------------- pfffff !!! I don't like my code !!!!!!!! :-) ---------
  986. ; ----------------- an animation vector is better ------------------
  987.  
  988.         ret
  989.  
  990. SUPER_MORFLAME ENDP
  991.  
  992. MRF_TEXT ENDS
  993.  
  994. END
  995.